package com.openweixin.sheknows.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author linxiaohui
 *
 */
public class SessionUtil {

	public static final String USER_ID_KEY="USER_ID";
	
	public static HttpServletRequest getRequest(){
		HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder
				.getRequestAttributes()).getRequest();
		return request;
	}
	
	public static HttpSession getSession(){
		return getRequest().getSession();
	}
	
	public static HttpSession getSession(boolean b){
		return getRequest().getSession(b);
	}
	
	public static Integer getUserID(){
		try {
			//(Integer)getSession().getAttribute(USER_ID_KEY)
			return 1;
		} catch (Exception e) {
			return 1;
		}
	}
}
